package edu.gdkm.dao;

import edu.gdkm.pojo.LoginInfo;
import org.apache.ibatis.annotations.*;

public interface ILoginInfoDao {
    @Select("select * from tab_login_info where id=#{id}")
    @Results({
            @Result(
                    property = "userInfo",
                    column = "uid",
                    one=@One(select = "edu.gdkm.dao.IUserInfoDao.queryUserInfoById")
            )
    })
    public LoginInfo queryLoginInfoById(Integer id);

    @Insert("insert into tab_login_info values(null,#{username},#{password},#{userInfo.id})")
    public Integer insertLoginInfo(LoginInfo loginInfo);

    @Update("update tab_login_info set username = #{username},password = #{password} where id = #{id}")
    public Integer updateLoginInfo(LoginInfo loginInfo);


    @Delete("delete from tab_login_info where id=#{id}")
    public Integer deleteLoginInfoById(Integer id);

    @Select("select * from tab_login_info where username=#{username} and password=#{password}")
    public LoginInfo loginInfoByUsernameAndPassword(@Param("username") String username,@Param("password") String password);


}
